package chap14;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.regex.Pattern;

public class ShowMethods {
	private static String usage="usage: \n"+
            "ShowMethods qualfied.class name\n"+
			"To Show all methods in class or:\n"+
            "ShowMethods qualfied.class.name word\n"+
			"To Search for methods involving 'word'";
	private static Pattern p=Pattern.compile("\\w+\\.");
	public static void main(String[] args) {
		int lines=0;
		try {
			Class<?> c=Class.forName("chap8.Piano");
			Method[] method=c.getMethods();
			for(Method method2:method){
				System.out.println(p.matcher(method2.toString()).replaceAll(""));
			}
			Constructor[] cstors=c.getConstructors();
			String id="s";
			for(Constructor cs:cstors){
				cs.newInstance(id);
				System.out.println(p.matcher(cs.toString()).replaceAll(""));
			}
		} catch (Exception e) {
			// TODO: handle exception
			System.out.println("No Such Class"+e);
		}
	}
			                

}
